{% extends "admin/base.html" %}
{% block title %} 分类管理 {% endblock %}
{% block menu %}
    {% set menu_current = 'category' %}
    {% include 'admin/menu.html' %}
{% endblock %}
{% block content %}
    <div id="where">当前位置：<span class="chosen">分类管理</span></div>
    <div id="category" class="content">
        <div class="option"><a href="{{ url_for('category_add') }}" class="button"><span>添加分类</span></a></div>
        <h3>所有分类</h3>
        <div class="data-list">
            <form method="post" action="">             
            <table cellspacing="0">
            <thead>
                <tr>
                    <th style="width:200px;">分类</th>
                    <th style="width:200px;">Slug</th>
                    <th>文章数量</th>
                    <th>排序</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
            {% if categories %}
                {% for i in categories %}
                <tr class="{{ loop.cycle('odd', 'even') }}">
                    <td><a href="entry/{{i.slug}}" title="">{{ i.title }}</a></td>
                    <td>{{ i.slug }}</td>
                    <td>{{ i.entries|count }}</td>
                    <td><input type="text" name="category_{{ i.id }}" class="text" style="width:50px;" value="{{ i.sort_order }}" /></td>
                    <td><a href="{{ url_for('category_edit',id=i.id) }}" title="修改分类">编辑</a> <a url="{{ url_for('category_del',id=i.id) }}" href="javascript:;" class="del">删除</a></td>
                </tr>
                {% endfor %}
                <tr>
                    <td><a href="entry/no-category" title="">未分类</a></td>
                    <td>no-category</td>
                    <td>{{ no_category_entry }}</td>
                    <td></td>
                    <td></td>
                </tr>
            {% else %}
                <tr>
                    <td colspan="5"><p class="no-data">暂无记录</p></td>
                </tr>
            {% endif %}
            </tbody>
            <tfoot>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td><input type="submit" class="button" value="更新" /></td>
                    <td></td>
                </tr>
            </tfoot>
            </table>
            </form>
        </div>
        
    </div>
{% endblock %}
{% block js %}
    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
    <script language="JavaScript" type="text/javascript">
    <!--
    $(function(){
        $('a.del').click(function(){
            var url = $(this).attr('url');
            var r=confirm("确定要删除吗？");
            if (r==true) {
                location.href = url;
            }	
        })
    })
    //-->
    </script>
{% endblock %}